package daybook.io.args;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import daybook.io.formatter.Format;

import static daybook.Resources.RESOURCES_NAME;
import static daybook.Resources.Usages.*;

@Parameters(separators = "=", resourceBundle = RESOURCES_NAME)
public class CommonArgs {
    @Parameter(names = {"--book", "-b"}, arity = 1,
            descriptionKey = BOOK_FILE)
    private String book = "book.json";

    @Parameter(names = {"--file", "-f"}, arity = 1,
            descriptionKey = TRANSACTIONS_FILE)
    private String file = "daybook.txt";

    @Parameter(names = {"--log"}, arity = 1,
            descriptionKey = LOG_LEVEL,
            validateWith = LogLevelValidator.class)
    private String logLevel = "off";

    @Parameter(names = {"--format"}, arity = 1,
            descriptionKey = INPUT_FORMAT,
            validateWith = InputFormatValidator.class,
            converter = FormatConverter.class)
    private Format format = Format.STRING;

    @Parameter(names = {"--help", "-h"}, descriptionKey = HELP, help = true)
    private boolean help;

    public String getBook() {
        return book;
    }

    public String getLogLevel() {
        return logLevel;
    }

    public String getFile() {
        return file;
    }

    public Format getFormat() {
        return format;
    }

    public boolean isHelp() {
        return help;
    }

    @Override
    public String toString() {
        return "CommonArgs{" +
                "book='" + book + '\'' +
                ", file='" + file + '\'' +
                ", logLevel='" + logLevel + '\'' +
                ", format=" + format +
                '}';
    }
}
